package org.jeecg.modules.demo.st.controller;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.demo.st.entity.*;
import org.jeecg.modules.demo.st.service.*;
import org.jeecg.modules.demo.st.vo.*;
import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.entity.SysDictItem;
import org.jeecg.modules.system.service.ISysDepartService;
import org.jeecg.modules.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;


/**
 * @Description: 所有接口
 * @Author: duankui
 * @Date:   2019-10-26
 * @Version: V1.0
 */
@Api(tags = "所有接口")
@RestController
@RequestMapping("/st/mobile")
@Slf4j
public class MobileController {
    @Autowired
    private IStProfessionService stProfessionService;
    @Autowired
    private IStClassService stClassService;
    @Autowired
    private IStStudentService stStudentService;
    @Autowired
    private IStStateJiluService stStateJiluService;
    @Autowired
    private IStPunishService stPunishService;
    @Autowired
    private ISysUserService sysUserService;
    @Autowired
    private ISysBaseAPI iSysBaseAPI;
    @Autowired
    private IStHonorService stHonorService;

    /**
     * 学院
     * 通过学校id获得学院列表 在校和非在校人数
     * getLists
     */
    @AutoLog(value = "通过学校id获得 在校和非在校人数")
    @ApiOperation(value="通过学校id获得 在校和非在校人数", notes="通过学校id获得 在校和非在校人数")
    @GetMapping(value = "/getLists")
   /* @RequiresPermissions("mobile:getLists")*/
    public Result<?> getLists(String parent_id) {
        List<DepartListVo> sysDeparts = stProfessionService.getLists();
        Result result = new Result();
        result.setResult(sysDeparts);
        return result;
    }


    /**
     * 年级列表
     * 通过年级字典编号grade获取年级列表 在校和非在校人数
     * getGradeLists
     */
    @AutoLog(value = "通过年级字典编号grade获取年级列表 在校和非在校人数")
    @ApiOperation(value="通过年级字典编号grade获取年级列表 在校和非在校人数", notes="通过年级字典编号grade获取年级列表 在校和非在校人数")
    @GetMapping(value = "/getGradeLists")
    public Result<?> getGradeLists(String departIds) {
            String grade = departIds;
            List<GradeListsVo> GradeListsVos = stProfessionService.getGradeLists(grade);
            Result result = new Result();
            result.setResult(GradeListsVos);
            return result;
        }

        /**
     * 年级列表
     * 通过年级字典编号grade获取年级列表 在校和非在校人数
     * getGradeListsSt
     */
    @AutoLog(value = "通过具体（班级，专业，年级，学院）信息 查看在校和非在校人数")
    @ApiOperation(value="通过具体（班级，专业，年级，学院）信息 在校和非在校人数", notes="通过具体（班级，专业，年级，学院）信息 在校和非在校人数")
    @GetMapping(value = "/getGradeListsSt")
    public Result<?> getGradeListsSt(String  departIds ,String professionIds ,String  fieldTwo ,String classIds ) {
        List<NationPersonsVo> studentVo = stProfessionService.getGradeListsSt(departIds,fieldTwo,professionIds,classIds);
        Result result = new Result();
        result.setResult(studentVo);
        return result;
    }

////////////////////////////////////////////////////////////////////////////饼图////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /**
         * 学院
         * 通过学校获取学院列表
         * getLists
         */
        @AutoLog(value = "通过学校获取学院饼图数据")
        @ApiOperation(value="通过学校获取学院饼图数据", notes="通过学校获取学院饼图数据")
        @GetMapping(value = "/getListsPicData")
        /* @RequiresPermissions("mobile:getLists")*/
        public Result<?> getListsPicData() {
        Map<String,Object> picData= stProfessionService.getListsPicDataBySchool();
        Result result = new Result();
        result.setResult(picData);
        return result;
    }
    /**
     * 学院
     * 通过学校获取学院列表
     * getLists
     */
    @AutoLog(value = "通过学院获取学院饼图数据")
    @ApiOperation(value="通过学院获取学院饼图数据", notes="通过学院获取学院饼图数据")
    @GetMapping(value = "/getListsPicDataByDepart")
    /* @RequiresPermissions("mobile:getLists")*/
    public Result<?> getListsPicDataByDepart(@RequestParam(required = true) String depart) {
        //获取当前用户
        Map<String,Object> picData= stProfessionService.getListsPicDataByDepart(depart);
        Result result = new Result();
        result.setResult(picData);
        return result;
    }
    /**
     * 学院
     * 通过专业获取饼图数据
     * getLists
     */
    @AutoLog(value = "通过专业获取饼图数据")
    @ApiOperation(value="通过专业获取饼图数据", notes="通过专业获取饼图数据")
    @GetMapping(value = "/getListsPicDataByProfession")
    /* @RequiresPermissions("mobile:getLists")*/
    public Result<?> getListsPicDataByProfession(@RequestParam(required = true) String professionIds) {
        //获取当前用户
        Map<String,Object> picData= stProfessionService.getListsPicDataByProfession(professionIds);
        Result result = new Result();
        result.setResult(picData);
        return result;
    }
    /**
     * 学院
     * 通过专业获取饼图数据
     * getLists
     */
    @AutoLog(value = "通过班级获取饼图数据")
    @ApiOperation(value="通过班级获取饼图数据", notes="通过班级获取饼图数据")
    @GetMapping(value = "/getListsPicDataByClass")
    /* @RequiresPermissions("mobile:getLists")*/
    public Result<?> getListsPicDataByClass(@RequestParam(required = true) String classIds) {
        //获取当前用户
        Map<String,Object> picData= stProfessionService.getListsPicDataByClass(classIds);
        Result result = new Result();
        result.setResult(picData);
        return result;
    }


    /**
     * 年级
     * 通过年级获取饼图数据
     * getListsGrade
     */
    @AutoLog(value = "通过年级获取饼图数据")
    @ApiOperation(value="通过年级获取饼图数据", notes="通过年级获取饼图数据")
    @GetMapping(value = "/getListsGrade")
    /* @RequiresPermissions("mobile:getListsGrade")*/
    public Result<?> getListsGrade(@RequestParam(required = true) String fieldTwos,String  departIds) {
        //获取当前用户
        Map<String,Object> picData= stProfessionService.getListsGrade(fieldTwos,departIds);
        Result result = new Result();
        result.setResult(picData);
        return result;
    }

////////////////////////////////////////////////////////////////////////////饼图////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /**
     * 筛选统计
     *筛选统计
     * getStatisticsStudentSYT
     */
    @AutoLog(value = "筛选统计")
    @ApiOperation(value="筛选统计", notes="筛选统计")
    @GetMapping(value = "/getStatisticsStudentSYT")
    /* @RequiresPermissions("stStudent:getHanPersons")*/
    public Result<?> getStatisticsStudentSYT(String  departIds ,String professionIds ,String classIds ,String  fieldTwo) {

        Map<String,Object> nationCou = stStudentService.getStatisticsStudentSYT(departIds,fieldTwo,professionIds,classIds);
        Result result=new Result();
        result.setResult(nationCou);
        return result;
    }


    /**
     * 专业
     * 通过学院id获取专业接口
     * getStProfession
     */
    @AutoLog(value = " 通过学院获取专业")
    @ApiOperation(value=" 通过学院获取专业", notes=" 通过学院获取专业")
    @GetMapping(value = "/getStProfession")
   /* @RequiresPermissions("stProfession:getStProfession")*/
    public Result<?> getStProfession(@RequestParam(required = true)   String id) {
        List<ProfessionListVo> stProfessions = stProfessionService.getStProfession(id);
        Result result=new Result();
        result.setResult(stProfessions);
        return result;
    }
    /**
     * 民族
     * 通过学院或年级或专业或班级获取民族人数
     * getNationPeople
     */
    @AutoLog(value = " 通过学院或年级或专业或班级获取民族人数")
    @ApiOperation(value=" 通过学院或年级或专业或班级获取民族人数", notes=" 通过学院或年级或专业或班级获取民族人数")
    @GetMapping(value = "/getNationPeople")
    /* @RequiresPermissions("stStudent:getNationPersons")*/
    public Result<?> getNationPeople(String college ,String fieldTwo ,String profession,String  stClass ) {
        List<NationPersonsVo> studentVo = stStudentService.getNationPeople(college,fieldTwo,profession,stClass);
        Result result=new Result();
        result.setResult(studentVo);
        return result;
    }

    /**
     * 民族
     * 通过学院或年级或专业或班级获取民族人数
     * getNationPeoples
     */
    @AutoLog(value = " 通过学院或年级或专业或班级获取民族人数")
    @ApiOperation(value=" 通过学院或年级或专业或班级获取民族人数", notes=" 通过学院或年级或专业或班级获取民族人数")
    @GetMapping(value = "/getNationPeoples")
    /* @RequiresPermissions("stStudent:getNationPersons")*/
    public Result<?> getNationPeoples(String  departIds ,String professionIds ,String classIds ,String  fieldTwo ) {
        List<NationPersonsVo> studentVo = stStudentService.getNationPeoples(departIds,fieldTwo,professionIds,classIds);
        Result result=new Result();
        result.setResult(studentVo);
        return result;
    }

    /**
     * 专业
     * 通过学院id获取专业接口
     * getStProfession
     */
    @AutoLog(value = " 通过民族获取人数")
    @ApiOperation(value=" 通过民族获取人数", notes=" 通过民族获取人数")
    @GetMapping(value = "/getNationPersons")
    /* @RequiresPermissions("stStudent:getNationPersons")*/
    public Result<?> getNationPersons(String  departIds ,String professionIds ,String classIds ,String fieldTwo ) {
        List<NationPersonsVo> studentListVos = stStudentService.getNationPersons(departIds,professionIds,classIds,fieldTwo);
        Result result=new Result();
        result.setResult(studentListVos);
        return result;
    }

    /**
     * 专业
     * 通过学院id获取专业接口
     * getStProfession
     */
    @AutoLog(value = " 通过政治面貌获取人数")
    @ApiOperation(value=" 通过政治面貌获取人数", notes=" 通过政治面貌获取人数")
    @GetMapping(value = "/getFacePersons")
    /* @RequiresPermissions("stStudent:getFacePersons")*/
    public Result<?> getFacePersons(String  departIds ,String professionIds ,String classIds ,String fieldTwo ) {
        List<NationPersonsVo> studentListVos = stStudentService.getFacePersons(departIds,professionIds,classIds,fieldTwo);
        Result result=new Result();
        result.setResult(studentListVos);
        return result;
    }

    /**
     * 学生
     * 通过家庭困难级别获取人数
     * getDifficults
     */
    @AutoLog(value = " 通过家庭困难级别获取人数")
    @ApiOperation(value=" 通过家庭困难级别获取人数", notes=" 通过家庭困难级别获取人数")
    @GetMapping(value = "/getDifficults")
    /* @RequiresPermissions("stStudent:getFacePersons")*/
    public Result<?> getDifficults(String  departIds ,String professionIds ,String classIds ,String fieldTwo ) {
        List<NationPersonsVo> studentListVos = stStudentService.getDifficults(departIds,professionIds,classIds,fieldTwo);
        Result result=new Result();
        result.setResult(studentListVos);
        return result;
    }

    /**
     * 学生
     * 通过心理健康获取人数
     * getPsychologicals
     */
    @AutoLog(value = " 通过心理健康获取人数")
    @ApiOperation(value=" 通过心理健康获取人数", notes=" 通过心理健康获取人数")
    @GetMapping(value = "/getPsychologicals")
    /* @RequiresPermissions("stStudent:getFacePersons")*/
    public Result<?> getPsychologicals(String  departIds ,String professionIds ,String classIds ,String fieldTwo ) {
        List<NationPersonsVo> studentListVos = stStudentService.getPsychologicals(departIds,professionIds,classIds,fieldTwo);
        Result result=new Result();
        result.setResult(studentListVos);
        return result;
    }

    /**
     * 学生
     * 通过处分获取人数
     * getPunishs
     */
    @AutoLog(value = " 通过处分获取人数")
    @ApiOperation(value=" 通过处分获取人数", notes=" 通过处分获取人数")
    @GetMapping(value = "/getPunishs")
    /* @RequiresPermissions("stStudent:getPunishs")*/
    public Result<?> getPunishs(String  departIds ,String professionIds ,String classIds ,String fieldTwo ) {
        List<NationPersonsVo> studentListVos = stStudentService.getPunishs(departIds,professionIds,classIds,fieldTwo);
        Result result=new Result();
        result.setResult(studentListVos);
        return result;
    }


    /**
     * 学生
     * 通过创业就业率获取人数
     * getGraduations
     */
    @AutoLog(value = " 通过创业就业率获取人数")
    @ApiOperation(value=" 通过创业就业率获取人数", notes=" 通过创业就业率获取人数")
    @GetMapping(value = "/getGraduations")
    /* @RequiresPermissions("stStudent:getFacePersons")*/
    public Result<?> getGraduations(String  departIds ,String professionIds ,String classIds ,String fieldTwo ) {
        List<NationPersonsVo> studentListVos = stStudentService.getGraduations(departIds,professionIds,classIds,fieldTwo);
        Result result=new Result();
        result.setResult(studentListVos);
        return result;
    }


    /**
     * 学生
     * 通过单亲孤儿获取人数
     * getSingles
     */
    @AutoLog(value = " 通过单亲孤儿获取人数")
    @ApiOperation(value=" 通过单亲孤儿获取人数", notes=" 通过单亲孤儿获取人数")
    @GetMapping(value = "/getSingles")
    /* @RequiresPermissions("stStudent:getFacePersons")*/
    public Result<?> getSingles(String  departIds ,String professionIds ,String classIds ,String fieldTwo ) {
        List<NationPersonsVo> studentListVos = stStudentService.getSingles(departIds,professionIds,classIds,fieldTwo);
        Result result=new Result();
        result.setResult(studentListVos);
        return result;
    }

    /**
     * 学生
     * 通过学业预警获取人数
     * getAcademicWarnings
     */
    @AutoLog(value = " 通过学业预警获取人数")
    @ApiOperation(value=" 通过学业预警获取人数", notes=" 通过学业预警获取人数")
    @GetMapping(value = "/getAcademicWarnings")
    /* @RequiresPermissions("stStudent:getFacePersons")*/
    public Result<?> getAcademicWarnings(String  departIds ,String professionIds ,String classIds ,String fieldTwo ) {
        List<NationPersonsVo> studentListVos = stStudentService.getAcademicWarnings(departIds,professionIds,classIds,fieldTwo);
        Result result=new Result();
        result.setResult(studentListVos);
        return result;
    }

    /**
     * 学生
     * 通过延迟毕业获取人数
     * getDelayedGraduations
     */
    @AutoLog(value = " 通过延迟毕业获取人数")
    @ApiOperation(value=" 通过延迟毕业获取人数", notes=" 通过延迟毕业获取人数")
    @GetMapping(value = "/getDelayedGraduations")
    /* @RequiresPermissions("stStudent:getFacePersons")*/
    public Result<?> getDelayedGraduations(String  departIds ,String professionIds ,String classIds ,String fieldTwo ) {
        List<NationPersonsVo> studentListVos = stStudentService.getDelayedGraduations(departIds,professionIds,classIds,fieldTwo);
        Result result=new Result();
        result.setResult(studentListVos);
        return result;
    }

    /**
     * 数据统计
     *数据统计
     * getStatisticsStudent
     */
    @AutoLog(value = "数据统计")
    @ApiOperation(value="数据统计", notes="数据统计")
    @GetMapping(value = "/getStatisticsStudent")
    /* @RequiresPermissions("stStudent:getHanPersons")*/
    public Result<?> getStatisticsStudent(String  departIds ,String professionIds ,String classIds ) {
        Map<String,Long> nationCou = stStudentService.getStatisticsStudent(departIds,professionIds,classIds);
        Result result=new Result();
        result.setResult(nationCou);
        return result;
    }

   /* *
     * 民族
     *汉族总人数
     * getHanPersons*/

    @AutoLog(value = " 汉族总人数和少数民族总人数")
    @ApiOperation(value=" 汉族总人数和少数民族总人数", notes=" 汉族总人数和少数民族总人数")
    @GetMapping(value = "/getHanPersons")
    /* @RequiresPermissions("stStudent:getHanPersons")*/
    public Result<?> getHanPersons(String  departIds ,String professionIds ,String classIds ) {
        Map<String,Long> nationCou = stStudentService.getHanPersons(departIds,professionIds,classIds);
        Result result=new Result();
        result.setResult(nationCou);
        return result;
    }

/*    *
     * 生源地
     *宁夏总人数和其他省份总人数
     * getBirthplacePersons*/

    @AutoLog(value = " 宁夏总人数和其他省份总人数")
    @ApiOperation(value=" 宁夏总人数和其他省份总人数", notes=" 宁夏总人数和其他省份总人数")
    @GetMapping(value = "/getBirthplacePersons")
     /*@RequiresPermissions("stStudent:getBirthplacePersons")*/
    public Result<?> getBirthplacePersons(String  departIds ,String professionIds ,String classIds) {
        Map<String,Long> nationCou = stStudentService.getBirthplacePersons(departIds,professionIds,classIds);
        Result result=new Result();
        result.setResult(nationCou);
        return result;
    }

/**
     * 党员情况
     *总人数和中共党员总人数
     * getPartyMembers
     */
    @AutoLog(value = " 总人数和中共党员总人数")
    @ApiOperation(value=" 总人数和中共党员总人数", notes=" 总人数和中共党员总人数")
    @GetMapping(value = "/getPartyMembers")
    /* @RequiresPermissions("stStudent:getPartyMembers")*/
    public Result<?> getPartyMembers(String  departIds ,String professionIds ,String classIds) {
        Map<String,Long> nationCou = stStudentService.getPartyMembers(departIds,professionIds,classIds);
        Result result=new Result();
        result.setResult(nationCou);
        return result;
    }



/**
     * 困难情况
     *总数和特别困难
     * getDifficultSituation
     */
    @AutoLog(value = " 总数和特别困难")
    @ApiOperation(value=" 总数和特别困难", notes=" 总数和特别困难")
    @GetMapping(value = "/getDifficultSituation")
/* @RequiresPermissions("stStudent:getPartyMembers")*/
    public Result<?> getDifficultSituation(String  departIds ,String professionIds ,String classIds) {
        Map<String,Long> nationCou = stStudentService.getDifficultSituation(departIds,professionIds,classIds);
        Result result=new Result();
        result.setResult(nationCou);
        return result;
    }



/*
    */
/**
     * 心理问题
     *总数和抑郁
     * getPsychologicalProblem
     */
    @AutoLog(value = " 总数和抑郁")
    @ApiOperation(value=" 总数和抑郁", notes=" 总数和抑郁")
    @GetMapping(value = "/getPsychologicalProblem")
/* @RequiresPermissions("stStudent:getPartyMembers")*/
    public Result<?> getPsychologicalProblem(String  departIds ,String professionIds ,String classIds) {
        Map<String,Long> nationCou = stStudentService.getPsychologicalProblem(departIds,professionIds,classIds);
        Result result=new Result();
        result.setResult(nationCou);
        return result;
    }

/*    *//**
     * 单亲孤儿
     *总数和孤儿
     * getSingleParentOrphan
     */
    @AutoLog(value = " 总数和孤儿")
    @ApiOperation(value=" 总数和孤儿", notes=" 总数和孤儿")
    @GetMapping(value = "/getSingleParentOrphan")
    /* @RequiresPermissions("stStudent:getPartyMembers")*/
    public Result<?> getSingleParentOrphan(String  departIds ,String professionIds ,String classIds) {
        Map<String,Long> nationCou = stStudentService.getSingleParentOrphan(departIds,professionIds,classIds);
        Result result=new Result();
        result.setResult(nationCou);
        return result;
    }

/*    *//**
     * 学业预警
     *总数和留级
     * getAcademicsWarninges
     */
    @AutoLog(value = " 总数和留级")
    @ApiOperation(value=" 总数和留级", notes=" 总数和留级")
    @GetMapping(value = "/getAcademicsWarninges")
    /* @RequiresPermissions("stStudent:getPartyMembers")*/
    public Result<?> getAcademicsWarninges(String  departIds ,String professionIds ,String classIds) {
        Map<String,Long> nationCou = stStudentService.getAcademicsWarninges(departIds,professionIds,classIds);
        Result result=new Result();
        result.setResult(nationCou);
        return result;
    }

    /**
     * 学生
     * 通过学院或年级或专业或班级获取省人数
     * getProvincePeoples
     */
    @AutoLog(value = " 通过学院或年级或专业或班级获取省人数")
    @ApiOperation(value=" 通过学院或年级或专业或班级获取省人数", notes="通过学院或年级或专业或班级获取省人数")
    @GetMapping(value = "/getProvincePeoples")
    /* @RequiresPermissions("stStudent:getProvincePeoples")*/
    public Result<?> getProvincePeoples(String college ,String fieldTwo ,String profession,String  stClass  ) {
        List<ProvinceVo> ProvincePeoples = stStudentService.getProvincePeoples(college,fieldTwo,profession,stClass);
        Result result=new Result();
        result.setResult(ProvincePeoples);
        return result;
    }

    /**
     * 通过学院或年级或专业或班级获取市人数
     * getCityPeoples
     */
    @AutoLog(value = " 通过学院或年级或专业或班级获取市人数")
    @ApiOperation(value=" 通过学院或年级或专业或班级获取市人数", notes="通过学院或年级或专业或班级获取市人数")
    @GetMapping(value = "/getCityPeoples")
    /* @RequiresPermissions("stStudent:getCityPeoples")*/
    public Result<?> getCityPeoples(String college ,String fieldTwo ,String profession,String  stClass  ) {
        List<CityVo> cityPeoples = stStudentService.getCityPeoples(college,fieldTwo,profession,stClass);
        Result result=new Result();
        result.setResult(cityPeoples);
        return result;
    }

    /**
     * 通过学院或年级或专业或班级获取县人数
     * getAreaPeoples
     */
    @AutoLog(value = " 通过学院或年级或专业或班级获取县人数")
    @ApiOperation(value=" 通过学院或年级或专业或班级获取县人数", notes="通过学院或年级或专业或班级获取县人数")
    @GetMapping(value = "/getAreaPeoples")
    /* @RequiresPermissions("stStudent:getAreaPeoples")*/
    public Result<?> getAreaPeoples(String college ,String fieldTwo ,String profession,String  stClass  ) {
        List<AreaVo> areaPeoples = stStudentService.getAreaPeoples(college,fieldTwo,profession,stClass);
        Result result=new Result();
        result.setResult(areaPeoples);
        return result;
    }

    /**
     * 通过学院或年级或专业或班级获取县人数
     * getAreaPeoples
     */
    @AutoLog(value = "学校可以看到所有，学院只能看到本学院的")
    @ApiOperation(value=" 学校可以看到所有，学院只能看到本学院的", notes="学校可以看到所有，学院只能看到本学院的")
    @GetMapping(value = "/getDepart")
    /* @RequiresPermissions("stStudent:getDepart")*/
    public Result<?> getDepart() {
        Result result=new Result();
        List<DepartVo> departs=null;
               //拿到当前人
            LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
            //拿到当前人的角色
            List<String> roles= iSysBaseAPI.getRolesByUsername(sysUser.getUsername());
            //确当前人 是 学校 还是学院
            if(roles.contains("leader")){
                //如果是学校
                departs = stStudentService.getDepart();
            }else {
                //如果是学院
                //查询老师是哪个学校getProvinces
            departs = stStudentService.getDepart(sysUser.getOrgCode());
        }
        result.setResult(departs);
        return result;
    }


    /**
     * 学生
     * 通过学生获取生源地人数
     * getStProfession
     */
    @AutoLog(value = " 通过学生获取生源地省人数")
    @ApiOperation(value=" 通过学生获取生源地省人数", notes="通过学生获取生源地省人数")
    @GetMapping(value = "/getProvinces")
    /* @RequiresPermissions("stStudent:getProvinces")*/
    public Result<?> getProvinces(String departs,String professions,String classs ,String fieldTwo) {
        List<ProvincesVo> provincesVos = stStudentService.getProvinces(departs,professions,classs,fieldTwo);
        Result result=new Result();
        result.setResult(provincesVos);
        return result;
    }

    /**
     * 学生
     * 通过学生获取生源地人数
     * getProvincesSt
     */
    @AutoLog(value = " 通过学生获取生源地省人数")
    @ApiOperation(value=" 通过学生获取生源地省人数", notes="通过学生获取生源地省人数")
    @GetMapping(value = "/getProvincesSt")
    /* @RequiresPermissions("stStudent:getProvinces")*/
    public Result<?> getProvincesSt(String departIds,String professionIds,String classIds ,String fieldTwo) {
        List<NationPersonsVo> provincesVos = stStudentService.getProvincesSt(departIds,professionIds,classIds,fieldTwo);
        Result result=new Result();
        result.setResult(provincesVos);
        return result;
    }

    /**
     * 学生
     * 通过学生获取生源地人数
     * getStProfession
     */
    @AutoLog(value = " 通过学生获取生源地市人数")
    @ApiOperation(value=" 通过学生获取生源地市人数", notes="通过学生获取生源地市人数")
    @GetMapping(value = "/getCitys")
    /* @RequiresPermissions("stStudent:getCitys")*/
    public Result<?> getCitys(String departs,String professions,String classs,String pid,String fieldTwo ) {
        List<ProvincesVo> provincesVos = stStudentService.getCitys(departs,professions,classs,pid,fieldTwo);
        Result result=new Result();
        result.setResult(provincesVos);
        return result;
    }


    /**
     * 学生
     * 通过学生获取生源地人数
     * getStProfession
     */
    @AutoLog(value = " 通过学生获取生源地县人数")
    @ApiOperation(value=" 通过学生获取生源地县人数", notes="通过学生获取生源地县人数")
    @GetMapping(value = "/getAreas")
    /* @RequiresPermissions("stStudent:getAreas")*/
    public Result<?> getAreas(String departs,String professions,String classs,String sid ,String fieldTwo) {
        List<ProvincesVo> provincesVos = stStudentService.getAreas(departs,professions,classs,sid,fieldTwo);
        Result result=new Result();
        result.setResult(provincesVos);
        return result;
    }

    /**
     * 班级
     *  通过专业id获取班级接口
     *  getStClasses
     *  @TODO 权限
     * @param
     * @return
     */
    @AutoLog(value = "获取班级")
    @ApiOperation(value="获取班级", notes="获取班级")
    @GetMapping(value = "/getStClasses")
//    @RequiresPermissions("stClass:getStClasses")
    public Result<?> getStClasses(@RequestParam(required = true) String profession) {
        List<ClassListVo> classListVos = stClassService.getListByProfession(profession);
        Result result=new Result();
        result.setResult(classListVos);
        return result;
    }

    /**
     * 获得学生信息
     * 通过班级id获得学生信息接口
     *getStudents
     */
    @AutoLog(value = "通过班级获得学生信息")
    @ApiOperation(value="通过班级获得学生信息", notes="通过班级获得学生信息")
    @GetMapping(value = "/getStStudent")
//    @RequiresPermissions("stStudent:getStStudent")
    public Result<?> StStudent(@RequestParam(required = true) String classId,
                                  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                  HttpServletRequest req) {
        List<StudentListVo> studentVos= stStudentService.getLists(classId,pageNo,pageSize);
        Result result=new Result();
        result.setResult(studentVos);
        return result;
    }
    /**
     * 获得学生信息
     * 通过班级id获得学生信息接口
     *getStudents
     */
    @AutoLog(value = "通过参数获得学生列表")
    @ApiOperation(value="通过参数获得学生列表", notes="通过参数获得学生列表")
    @GetMapping(value = "/getStStudentData")
//    @RequiresPermissions("stStudent:getStStudent")
    public Result<?> getStStudentData(String classId,
                               String departId,
                               String professionId,
                               String nationality,
                               String status,
                               String province,
                               String city,
                               String area,
                               String fieldTwo,
                               String face,
                               String difficult,
                               String psychological,
                               String graduation,
                               String single,
                               String academicWarning,
                               String delayedGraduation,
                               @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                               @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                               HttpServletRequest req) {
        if((StringUtils.isBlank(classId) )&&
                StringUtils.isBlank(departId) &&
                StringUtils.isBlank(professionId) &&
                StringUtils.isBlank(nationality) &&
                StringUtils.isBlank(province) &&
                StringUtils.isBlank(city) &&
                StringUtils.isBlank(area) &&
                StringUtils.isBlank(status)&&
                StringUtils.isBlank(fieldTwo)&&
                StringUtils.isBlank(face)&&
                StringUtils.isBlank(difficult)&&
                StringUtils.isBlank(psychological)&&
                StringUtils.isBlank(graduation)&&
                StringUtils.isBlank(single)&&
                StringUtils.isBlank(academicWarning)&&
                StringUtils.isBlank(delayedGraduation)
                ){
            return Result.error("您的参数不正确，请确认后再进行访问！");
        }
        List<StudentListVo> studentVos= stStudentService.getLists(classId,departId,professionId,nationality, status,province,city,area,fieldTwo,face,difficult,psychological,graduation,single,academicWarning,delayedGraduation,pageNo,pageSize);
        Result result=new Result();
        result.setResult(studentVos);
        return result;
    }




    /**
     * 获得学生信息
     * 通过班级id获得学生信息接口
     * @TODO 权限
     *getStudents
     */
    @AutoLog(value = "更新学生状态")
    @ApiOperation(value="更新学生状态", notes="更新学生状态")
    @PostMapping(value = "/updateStatus")
//    @RequiresPermissions("stStudent:getStStudent")
    public Result<?> updateStatus(@RequestBody StStateJiluForAdmin stStateJiluForAdmin) {

        //如果在过
        //拿到所有学生的id
        String ids=stStateJiluForAdmin.getStuIds();
        //拿到不在校的人
        List<StStateJiluForAdmin> getStStateIf = stStudentService.getStatus(ids);
        boolean ok=false;
        //判断  下面拿到的学生id是否在不在校里面
        if(getStStateIf.size()>0){
            System.out.println("你选择的里面有离校状态，请注意筛选");
        }else {
            //全都在校
            //更新状态
            QueryWrapper<StStudent> stStudentWrapper = new QueryWrapper<>();
            StStudent stStudent = new StStudent();
            stStudentWrapper.in("id", ids.split(","));
            String[] split = ids.split(",");
            //拿到当前人
            LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
            //保持多个学生状态
            for (int i = 0; i < split.length; i++) {
                StStateJilu stStateJilu1 = new StStateJilu();
                stStudent.setStatus(stStateJiluForAdmin.getTheReason());
                stStateJilu1.setTheReason(stStateJiluForAdmin.getTheReason());
                stStateJilu1.setStName(split[i]);
                stStateJilu1.setCollege(iSysBaseAPI.getDepartIdsByOrgCode(sysUser.getOrgCode()));
                stStateJilu1.setDepartureTime(stStateJiluForAdmin.getDepartureTime());
                stStateJilu1.setApprover(stStateJiluForAdmin.getApprover());
                stStateJilu1.setBackTime(stStateJiluForAdmin.getBackTime());
                stStateJilu1.setConfirmor(stStateJiluForAdmin.getConfirmor());
                stStateJilu1.setConfirmTime(stStateJiluForAdmin.getConfirmTime());
                stStateJilu1.setFieldOne(stStateJiluForAdmin.getFieldOne());
                stStateJiluService.save(stStateJilu1);
            }
            ok = stStudentService.update(stStudent, stStudentWrapper);
        }
            Result result = new Result();
            result.setResult(ok);
            result.setSuccess(ok);
            result.setMessage(ok ? "操作成功" : "操作失败！请检查您的参数！");
            return result;
        }






    /**
     * 获得学生信息
     * 通过班级id获得学生信息接口
     * @TODO 权限
     *getStudents
     */
    @AutoLog(value = "通过id 或者学号 获得学生")
    @ApiOperation(value="通过id 或者学号 获得学生", notes="通过id 或者学号 获得学生")
    @GetMapping(value = "/getStudentByStuIdOrId")
//    @RequiresPermissions("stStudent:getStStudent")
    public Result<?> getStudentByStuIdOrId(String keyword,String key,String fieldTwo,String nationality,String face,
                                           String punish,String graduation,String single,String difficult,String psychological,String academicWarning,String delayedGraduation,String departId,
                                    HttpServletRequest req) {
        if(keyword==null){
            keyword=key;
        }
        QueryWrapper<StStudent> stStudentWrapper=new QueryWrapper<>();
        if(StringUtils.isNotBlank(keyword)){
            stStudentWrapper.like("student_id",keyword).or().like("st_name",keyword).or().like("id",keyword);
        }
        stStudentWrapper.eq("deleted","0");
        stStudentWrapper.eq("field_one","0");
        if(StringUtils.isNotBlank(departId)){
            stStudentWrapper.eq("college",departId);
        }
        if(StringUtils.isNotBlank(fieldTwo)){
            //stStudentWrapper.eq("field_two",fieldTwo);
            stStudentWrapper.in("field_two", fieldTwo.split(","));
            //String[] split = college.split(",");
        }
        if(StringUtils.isNotBlank(nationality)){
            //stStudentWrapper.eq("nationality",nationality);
            stStudentWrapper.in("nationality", nationality.split(","));
        }
        if(StringUtils.isNotBlank(face)){
            //stStudentWrapper.eq("face",face);
            stStudentWrapper.in("face", face.split(","));
        }
        if(StringUtils.isNotBlank(punish)){
           // stStudentWrapper.eq("punish",punish);
            stStudentWrapper.in("punish", punish.split(","));
        }
        if(StringUtils.isNotBlank(graduation)){
            //stStudentWrapper.eq("graduation",graduation);
            stStudentWrapper.in("graduation", graduation.split(","));
        }
        if(StringUtils.isNotBlank(single)){
            //stStudentWrapper.eq("single",single);
            stStudentWrapper.in("single", single.split(","));
        }
        if(StringUtils.isNotBlank(difficult)){
           // stStudentWrapper.eq("difficult",difficult);
            stStudentWrapper.in("difficult", difficult.split(","));
        }
        if(StringUtils.isNotBlank(psychological)){
            //stStudentWrapper.eq("psychological",psychological);
            stStudentWrapper.in("psychological", psychological.split(","));
        }
        if(StringUtils.isNotBlank(academicWarning)){
            //stStudentWrapper.eq("academic_warning",academicWarning);
            stStudentWrapper.in("academic_warning", academicWarning.split(","));
        }
        if(StringUtils.isNotBlank(delayedGraduation)){
            //stStudentWrapper.eq("delayed_graduation",delayedGraduation);
            stStudentWrapper.in("delayed_graduation", delayedGraduation.split(","));
        }
        /*stStudentWrapper.eq("field_two","fieldTwo");
        stStudentWrapper.eq("nationality","nationality");*/
        /*List<FilterVo> filterVo= stStudentService.getfilterVos(fieldTwo,nationality);*/
        List<StStudent> stStudents = stStudentService.list(stStudentWrapper);
        Result result=new Result();
        List<DictModel> models=new ArrayList<>();
        for (StStudent stStudent : stStudents) {
            DictModel dictModel=new DictModel();
            dictModel.setValue(stStudent.getId());
            dictModel.setText(stStudent.getStName()+"("+stStudent.getStudentId()+")");
            dictModel.setPhone(stStudent.getStPhoto());
            dictModel.setStName(stStudent.getStName());
            dictModel.setStId(stStudent.getStudentId());
            models.add(dictModel);
        }
        result.setResult(models);
        return result;
    }


    /**
     * 学生
     * 通过年级民族统计学生人数
     * getStProfession
     */
    @AutoLog(value = " 通过年级民族统计学生人数")
    @ApiOperation(value=" 通过年级民族统计学生人数", notes="通过年级民族统计学生人数")
    @GetMapping(value = "/getStatistics")
    /* @RequiresPermissions("stStudent:getAreas")*/
    public Result<?> getStatistics(String keyword,String departs,String nationality ,String fieldTwo,String face,
                                   String punish,String graduation,String single,String difficult,String psychological,String academicWarning,String delayedGraduation) {
        List<StatisticsVo> statisticsVo = stStudentService.getStatistics(keyword,departs,
                nationality!=null?nationality.split(","):null,
                fieldTwo!=null?fieldTwo.split(","):null,
                face!=null?face.split(","):null,
                punish!=null?punish.split(","):null,
                graduation!=null?graduation.split(","):null,
                single!=null?single.split(","):null,
                difficult!=null?difficult.split(","):null,
                psychological!=null?psychological.split(","):null,
                academicWarning!=null?academicWarning.split(","):null,
        delayedGraduation!=null?delayedGraduation.split(","):null);
        Result result=new Result();
        result.setResult(statisticsVo);
        return result;
    }

    /**
     * 学生
     * 通过状态获得所有困难学生列表
     * getSchoolLeaverList
     */
    @AutoLog(value = " 通过状态获得所有困难学生列表")
    @ApiOperation(value=" 通过状态获得所有困难学生列表", notes="通过状态获得所有困难学生列表")
    @GetMapping(value = "/getSchoolDifficult")
    /* @RequiresPermissions("stStudent:getAreas")*/
    public Result<?> getSchoolDifficult(String college ,
                                         @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                         @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                         HttpServletRequest req) {
        StStudent stStudent=new StStudent();
        stStudent.setCollege(college);
        QueryWrapper<StStudent> queryWrapper = QueryGenerator.initQueryWrapper(stStudent, req.getParameterMap());
        queryWrapper.ne("difficult","1");
        Page<StStudent> page = new Page<StStudent>(pageNo, pageSize);
        IPage<StStudent> pageList = stStudentService.page(page, queryWrapper);
        return Result.ok(pageList);
    }


    /**
     * 学生
     * 通过状态获得所有心理问题学生列表
     * getSchoolPsychological
     */
    @AutoLog(value = " 通过状态获得所有心理问题学生列表")
    @ApiOperation(value=" 通过状态获得所有心理问题学生列表", notes="通过状态获得所有心理问题学生列表")
    @GetMapping(value = "/getSchoolPsychological")
    /* @RequiresPermissions("stStudent:getAreas")*/
    public Result<?> getSchoolPsychological(String college ,
                                        @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                        @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                        HttpServletRequest req) {
        StStudent stStudent=new StStudent();
        stStudent.setCollege(college);
        QueryWrapper<StStudent> queryWrapper = QueryGenerator.initQueryWrapper(stStudent, req.getParameterMap());
        queryWrapper.ne("psychological","1");
        Page<StStudent> page = new Page<StStudent>(pageNo, pageSize);
        IPage<StStudent> pageList = stStudentService.page(page, queryWrapper);
        return Result.ok(pageList);
    }

    /**
     * 学生
     * 通过学生信息获得所有创业就业学生列表
     * getSchoolGraduation
     */
    @AutoLog(value = " 通过学生信息获得所有创业就业学生列表")
    @ApiOperation(value=" 通过学生信息获得所有创业就业学生列表", notes="通过学生信息获得所有创业就业学生列表")
    @GetMapping(value = "/getSchoolGraduation")
    /* @RequiresPermissions("stStudent:getAreas")*/
    public Result<?> getSchoolGraduation(String college ,
                                            @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                            @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                            HttpServletRequest req) {
        StStudent stStudent=new StStudent();
        stStudent.setCollege(college);
        QueryWrapper<StStudent> queryWrapper = QueryGenerator.initQueryWrapper(stStudent, req.getParameterMap());
        queryWrapper.ne("graduation","1");
        queryWrapper.ne("graduation","2");
        Page<StStudent> page = new Page<StStudent>(pageNo, pageSize);
        IPage<StStudent> pageList = stStudentService.page(page, queryWrapper);
        return Result.ok(pageList);
    }

    /**
     * 学生
     * 通过学生信息获得所有单亲孤儿学生列表
     * getSchoolSingle
     */
    @AutoLog(value = " 通过学生信息获得所有单亲孤儿学生列表")
    @ApiOperation(value=" 通过学生信息获得所有单亲孤儿学生列表", notes="通过学生信息获得所有单亲孤儿学生列表")
    @GetMapping(value = "/getSchoolSingle")
    /* @RequiresPermissions("stStudent:getAreas")*/
    public Result<?> getSchoolSingle(String college ,
                                         @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                         @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                         HttpServletRequest req) {
        StStudent stStudent=new StStudent();
        stStudent.setCollege(college);
        QueryWrapper<StStudent> queryWrapper = QueryGenerator.initQueryWrapper(stStudent, req.getParameterMap());
        queryWrapper.ne("single","1");
        Page<StStudent> page = new Page<StStudent>(pageNo, pageSize);
        IPage<StStudent> pageList = stStudentService.page(page, queryWrapper);
        return Result.ok(pageList);
    }

    /**
     * 学生
     * 通过学生信息获得所有学业预警学生列表
     * getSchoolAcademicWarning
     */
    @AutoLog(value = " 通过学生信息获得所有学业预警学生列表")
    @ApiOperation(value=" 通过学生信息获得所有学业预警学生列表", notes="通过学生信息获得所有学业预警学生列表")
    @GetMapping(value = "/getSchoolAcademicWarning")
    /* @RequiresPermissions("stStudent:getAreas")*/
    public Result<?> getSchoolAcademicWarning(String college ,
                                     @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                     @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                     HttpServletRequest req) {
        StStudent stStudent=new StStudent();
        stStudent.setCollege(college);
        QueryWrapper<StStudent> queryWrapper = QueryGenerator.initQueryWrapper(stStudent, req.getParameterMap());
        queryWrapper.ne("academicw_arning","1");
        Page<StStudent> page = new Page<StStudent>(pageNo, pageSize);
        IPage<StStudent> pageList = stStudentService.page(page, queryWrapper);
        return Result.ok(pageList);
    }

    /**
     * 学生
     * 通过学生信息获得所有延迟毕业生列表
     * getSchoolDelayedGraduation
     */
    @AutoLog(value = " 通过学生信息获得所有延迟毕业生列表")
    @ApiOperation(value=" 通过学生信息获得所有延迟毕业生列表", notes="通过学生信息获得所有延迟毕业生列表")
    @GetMapping(value = "/getSchoolDelayedGraduation")
    /* @RequiresPermissions("stStudent:getAreas")*/
    public Result<?> getSchoolDelayedGraduation(String college ,
                                              @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                              @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                              HttpServletRequest req) {
        StStudent stStudent=new StStudent();
        stStudent.setCollege(college);
        QueryWrapper<StStudent> queryWrapper = QueryGenerator.initQueryWrapper(stStudent, req.getParameterMap());
        queryWrapper.ne("delayed_graduation","1");
        Page<StStudent> page = new Page<StStudent>(pageNo, pageSize);
        IPage<StStudent> pageList = stStudentService.page(page, queryWrapper);
        return Result.ok(pageList);
    }

    /**
     * 学生
     * 通过状态获得所有离校学生列表
     * getSchoolLeaverList
     */
    @AutoLog(value = " 通过状态获得所有离校学生列表")
    @ApiOperation(value=" 通过状态获得所有离校学生列表", notes="通过状态获得所有离校学生列表")
    @GetMapping(value = "/getSchoolLeaverList")
    /* @RequiresPermissions("stStudent:getAreas")*/
    public Result<?> getSchoolLeaverList(String college ,
                                         @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                         @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                         HttpServletRequest req) {
        StStudent stStudent=new StStudent();
        stStudent.setCollege(college);
        QueryWrapper<StStudent> queryWrapper = QueryGenerator.initQueryWrapper(stStudent, req.getParameterMap());
        queryWrapper.ne("status","1");
        Page<StStudent> page = new Page<StStudent>(pageNo, pageSize);
        IPage<StStudent> pageList = stStudentService.page(page, queryWrapper);
        return Result.ok(pageList);
    }


    /**
     * 学生
     * 通过专业id获得班级
     * getSchoolClass
     */
    @AutoLog(value = " 通过专业id获得班级列表")
    @ApiOperation(value=" 通过专业id获得班级", notes="通过专业id获得班级")
    @GetMapping(value = "/getSchoolClass")
    /* @RequiresPermissions("stStudent:getAreas")*/
    public Result<?> getSchoolClass(String profession ,
                                         @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                         @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                         HttpServletRequest req) {
        StClass stClass = new StClass();
        stClass.setProfession(profession);
        QueryWrapper<StClass> queryWrapper = QueryGenerator.initQueryWrapper(stClass, req.getParameterMap());
        queryWrapper.ne("profession","profession");
        Page<StClass> page = new Page<StClass>(pageNo, pageSize);
        IPage<StClass> pageList = stClassService.page(page, queryWrapper);
        return Result.ok(pageList);
    }

    /**
     * 学生
     * 通过学院id获得专业
     * getSchoolProfession
     */
    @AutoLog(value = " 通过学院id获得专业列表")
    @ApiOperation(value=" 通过学院id获得专业", notes="通过学院id获得专业")
    @GetMapping(value = "/getSchoolProfession")
    /* @RequiresPermissions("stStudent:getAreas")*/
    public Result<?> getSchoolProfession(String college ,
                                    @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                    @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                    HttpServletRequest req) {
        StProfession stProfession = new StProfession();
        stProfession.setCollege(college);
        QueryWrapper<StProfession> queryWrapper = QueryGenerator.initQueryWrapper(stProfession, req.getParameterMap());
        queryWrapper.ne("college","college");
        Page<StProfession> page = new Page<StProfession>(pageNo, pageSize);
        IPage<StProfession> pageList = stProfessionService.page(page, queryWrapper);
        return Result.ok(pageList);
    }


    /**
     * 学生
     * 通过学生学号获得离校记录列表
     * getSchoolRecording
     */
    @AutoLog(value = " 通过学生学号获得离校记录列表")
    @ApiOperation(value=" 通过学生学号获得离校记录列表", notes="通过学生学号获得离校记录列表")
    @GetMapping(value = "/getSchoolRecording")
    public Result<?> getSchoolRecording(String stName ,
                                        HttpServletRequest req) throws ParseException {
        List<StStateJilu> stStateJilus = stStateJiluService.getSchoolRecording(stName);
        Result result=new Result();
        result.setResult(stStateJilus);
        return result;
    }


    /**
     * 学生
     * 通过学生学号获得处分记录列表
     * getSchoolPunish
     */
    @AutoLog(value = " 通过学生学号获得处分记录列表")
    @ApiOperation(value=" 通过学生学号获得处分记录列表", notes="通过学生学号获得处分记录列表")
    @GetMapping(value = "/getSchoolPunish")
    public Result<?> getSchoolPunish(String stName ,
                                        HttpServletRequest req) throws ParseException {
        List<StPunish> SchoolPunish = stPunishService.getSchoolPunish(stName);
        Result result=new Result();
        result.setResult(SchoolPunish);
        return result;
    }



    /**
     * 更新所有离校学生状态
     * 更新所有离校学生状态
     * @TODO 权限
     *getStudents
     */
    @AutoLog(value = "更新所有离校学生状态")
    @ApiOperation(value="更新所有离校学生状态", notes="更新所有离校学生状态")
    @PostMapping(value = "/updateStatusLeaverList")
//    @RequiresPermissions("stStudent:updateStatusLeaverList")
    public Result<?> updateStatusLeaverList(@RequestBody StStateJiluForAdmin stStateJiluForAdmin) {
        //如果在过
        //拿到所有学生的id
        String ids=stStateJiluForAdmin.getStuIds();
            //全都在校
            //更新状态
            //QueryWrapper<StStudent> stStgetSchoolRecordingudentWrapper = new QueryWrapper<>();
            //StStudent stStudent = new StStudent();
            //stStudentWrapper.in("id", ids.split(","));
            //String[] split = ids.split(",");
            //拿到当前人
            LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
            //更新学生信息的状态
            stStudentService.updateStatuses(ids);
            //拿到需要更新人的学号
            List<String> getStatuses = stStudentService.getStatuses(ids);
            String aaa = getStatuses.get(0);
            //更新学生最新信息记录的信息
            String join = String.join(",", getStatuses);
            List<StStateJilu>  updatestStateJilu = stStateJiluService.getLast(join);
            for(StStateJilu a:updatestStateJilu){
                a.setTheReason("1");
                stStateJiluService.updateById(a);
            }
            UpdateState update = new UpdateState();
            update.setUpdatestStateJilu(updatestStateJilu);
           /* stStateJiluService.updateById(updatestStateJilu);*/
            Result result = new Result();
            result.setResult(update);
            result.setMessage("操作成功" );
            //: "操作失败！请检查您的参数！"
            return result;
}


    /**
     * 更新所有离校学生状态
     * 更新所有离校学生状态
     * @TODO 权限
     *getStudents
     */
   /* @AutoLog(value = "更新所有离校学生状态")
    @ApiOperation(value="更新所有离校学生状态", notes="更新所有离校学生状态")
    @PostMapping(value = "/updateStatusLeaverList")
//    @RequiresPermissions("stStudent:updateStatusLeaverList")
    public Result<?> updateStatusLeaverList(@RequestBody StStudent stStudent) {
        //如果在过
        //拿到所有学生的id
        String college=stStudent.getCollege();
        //拿到不在校的人
        List<StStudent> getStStateIf = stStudentService.getSchoolLeaverList(college);
        boolean ok=false;
        //判断  下面拿到的学生id是否在不在校里面
        if(getStStateIf.size()>0){
           //全都在校
            //更新状态
            QueryWrapper<StStudent> stStudentWrapper = new QueryWrapper<>();
          *//*  stStudentWrapper.in("id", ids.split(","));*//*
            String[] split = college.split(",");
            //保持多个学生状态
            for (int i = 0; i < split.length; i++) {
                stStudent.setStudentId(stStudent.getStudentId());
                stStudent.setStatus(stStudent.getStatus());
                stStudent.setId(stStudent.getId());
            }
            ok = stStudentService.updateById(stStudent);
        }
        Result result = new Result();
        result.setResult(ok);
        result.setSuccess(ok);
        result.setMessage(ok ? "操作成功" : "操作失败！请检查您的参数！");
        return result;
    }*/

    /**
     * 获得学生信息
     * 通过班级id获得学生信息接口
     * @TODO 权限
     *getStudents
     */
    @AutoLog(value = "获得学生信息")
    @ApiOperation(value="获得学生信息", notes="获得学生信息")
    @GetMapping(value = "/getStudentInfo")
//    @RequiresPermissions("stStudent:getStStudent")
    public Result<?> getStudentInfo(@RequestParam(required = true) String stuId,
                               HttpServletRequest req) {
        List<StatisticsVo> stStateJilu = stStateJiluService.getFrequency(stuId);
        List<StatisticsVo> stSanctions = stPunishService.getSanctions(stuId);
        Map<String,Object> nationCou = stStudentService.getStudentInfo(stuId,stStateJilu,stSanctions);
        Result result=new Result();
        result.setResult(nationCou);
        return result;
    }
 /**
     * 获得学生最近一次的请假记录
     * 获得学生最近一次的请假记录
     * getStudentLastestJilu
     */
    @AutoLog(value = "获得学生最近一次的请假记录")
    @ApiOperation(value="获得学生最近一次的请假记录", notes="获得学生最近一次的请假记录")
    @GetMapping(value = "/getStudentLastestJilu")
//    @RequiresPermissions("stStudent:getStStudent")
    public Result<?> getStudentLastestJilu(@RequestParam(required = true) String stuId,
                               HttpServletRequest req) {

        List<StStateJilu> stStateJilu = stStateJiluService.getLast(stuId);
        Result result=new Result();
        result.setResult(stStateJilu);
        return result;
    }

    /**
     * 通过学号获得学生荣誉列表
     * 通过学号获得学生荣誉列表
     * getStudentHonor
     */
    @AutoLog(value = "通过学号获得学生荣誉列表")
    @ApiOperation(value="通过学号获得学生荣誉列表", notes="通过学号获得学生荣誉列表")
    @GetMapping(value = "/getStudentHonor")
//    @RequiresPermissions("stStudent:getStStudent")
    public Result<?> getStudentHonor(@RequestParam(required = true) String stuId,
                                           HttpServletRequest req) {
        List<StHonor> stStateJilu = stHonorService.getStudentHonor(stuId);
        Result result=new Result();
        result.setResult(stStateJilu);
        return result;
    }

    /**
     * 通过审核状态获得待审核荣誉列表
     * 通过审核状态获得待审核荣誉列表
     * getStudentReviewHonors
     */
    @AutoLog(value = "通过审核状态获得待审核荣誉列表")
    @ApiOperation(value="通过审核状态获得待审核荣誉列表", notes="通过审核状态获得待审核荣誉列表")
    @GetMapping(value = "/getStudentReviewHonors")
//    @RequiresPermissions("stStudent:getStStudent")
    public Result<?> getStudentReviewHonors(@RequestParam(required = true) String stuId,
                                            HttpServletRequest req) {
        List<StHonor> stStateJilu = stHonorService.getStudentReviewHonors(stuId);
        Result result=new Result();
        result.setResult(stStateJilu);
        return result;
    }

    /**
     * 通过学号更新学生荣誉状态
     * 通过学号更新学生荣誉状态
     * getStudentHonorReview
     */
    @AutoLog(value = "通过学号更新学生荣誉状态")
    @ApiOperation(value="通过学号更新学生荣誉状态", notes="通过学号更新学生荣誉状态")
    @GetMapping(value = "/getStudentHonorBy")
//    @RequiresPermissions("stStudent:getStStudent")
    public Result<?> getStudentHonorBy(@RequestParam(required = true) String stuId,String review,
                                     HttpServletRequest req) {
        List<StHonor> stStateJilu = stHonorService.getStudentHonorBy(stuId,review);
        Result result=new Result();
        result.setResult(stStateJilu);
        return result;
    }


    /**
     * 学生状态记录
     * 保存学生状态接口
     * addNew
     */
    @AutoLog(value = "保存学生状态接口")
    @ApiOperation(value="保存学生状态接口", notes="保存学生状态接口")
    @PostMapping(value = "/addNew")
   /* @RequiresPermissions("stStateJilu:addNew")*/
    public Result<?> addNew(@RequestBody StStateJilu stStateJilu) {
        //获取当前用户
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        stStateJilu.setApprover(sysUser.getId());
        stStateJilu.setSort(sysUser.getRealname());
        stStateJiluService.save(stStateJilu);
        StStudent stStudent=new StStudent();
        stStudent.setId(stStateJilu.getStName());
        stStudent.setStatus(stStateJilu.getTheReason());
        stStudentService.updateById(stStudent);
        return Result.ok("保存成功！");
    }



    /**
     * 学生处分记录
     * 保存学生处分接口
     * addNewPunish
     */
    @AutoLog(value = "保存学生处分接口")
    @ApiOperation(value="保存学生处分接口", notes="保存学生处分接口")
    @PostMapping(value = "/addNewPunish")
    /* @RequiresPermissions("stStateJilu:addNew")*/
    public Result<?> addNewPunish(@RequestBody StPunish stPunish) {
        //获取当前用户
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        stPunish.setRegisterPerson(sysUser.getId());
        stPunish.setFieldOne(sysUser.getRealname());
        stPunishService.save(stPunish);
        StStudent stStudent=new StStudent();
        stStudent.setId(stPunish.getStName());
        stStudent.setStatus(stPunish.getPunish());
        stStudentService.updateById(stStudent);
        return Result.ok("保存成功！");
    }

    /**
     * 学生处分记录
     * 通过学生学号获得处分记录次数
     * getSanctions
     */
    @AutoLog(value = " 通过学生学号获得处分记录次数")
    @ApiOperation(value=" 通过学生学号获得处分记录次数", notes="通过学生学号获得处分记录次数")
    @GetMapping(value = "/getSanctions")
    /* @RequiresPermissions("stStudent:getAreas")*/
    public Result<?> getSanctions(
                                  @RequestParam(required = true)String stuId ,
                                  HttpServletRequest req) {
        List<StatisticsVo> stSanctions = stPunishService.getSanctions(stuId);
        Result result=new Result();
        result.setResult(stSanctions);
        return result;
    }

    /**
     * 学生状态记录
     * 确认归校
     *comeback
     */
    @AutoLog(value = "确认归校")
    @ApiOperation(value="确认归校", notes="确认归校")
    @PostMapping(value = "/comeback")
   /* @RequiresPermissions("stStateJilu:comeback")*/
    public Result<?> comeback(@RequestBody StStateJilu stStateJilu) {
        boolean ok = stStateJiluService.comeback(stStateJilu);
        Result result=new Result();
        if(ok == true){
            result.setResult(ok);
            result.setSuccess(ok);
        }
        else {
            result.error500("操作失败");
        }
        return result;
    }

    /**
     * 学生状态记录
     * 离校次数
     *comeback
     */
    @AutoLog(value = "离校次数")
    @ApiOperation(value="离校次数", notes="离校次数")
    @PostMapping(value = "/getFrequency")
    /* @RequiresPermissions("stStateJilu:getFrequency")*/
    public Result<?> getFrequency(@RequestParam(required = true) String stuId,
                                           HttpServletRequest req) {

        List<StatisticsVo> stStateJilu = stStateJiluService.getFrequency(stuId);
        Result result=new Result();
        result.setResult(stStateJilu);
        return result;
    }

    /**
     * 学生状态记录
     * 离校记录
     *comeback
     */
    @AutoLog(value = "离校记录")
    @ApiOperation(value="离校记录", notes="离校记录")
    @PostMapping(value = "/getRecording")
    /* @RequiresPermissions("stStateJilu:getRecording")*/
    public Result<?> getRecording(@RequestParam(required = true) String stuId,
                                  HttpServletRequest req) {

        List<StStateJilu> stStateJilu = stStateJiluService.getRecording(stuId);
        Result result=new Result();
        result.setResult(stStateJilu);
        return result;
    }



    /**
     * 修改密码
     * @param json
     * @return
     */
    @RequestMapping(value = "/updatePassword", method = RequestMethod.POST)
    public Result<?> changPassword(@RequestBody JSONObject json) {
        //获取当前用户
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String oldpassword = json.getString("oldpassword");
        String password = json.getString("password");
        String confirmpassword = json.getString("confirmpassword");
        return sysUserService.resetPassword(sysUser.getUsername(),oldpassword,password,confirmpassword);
    }


}
